<?php

namespace App\Controller;

use Hyperf\Contract\OnReceiveInterface;

class TcpServer implements OnReceiveInterface
{
    public function onReceive($server, $fd, $reactorId, $data): void
    {
        $server->send($fd, '接收到了'.$data);
    }

    public function onClose($server, $fd, $reactorId)
    {
        echo "tcp关闭\n";
        $server->send($fd,"再见");
    }
}